import preutils from '@/common/preutils.js'
import check from '@/common/check.js'
import utils from '../../util/printUtils.js'
import tool from './printOrderDataTool.js'
export default {
	printTitle: function(outputStream,e) {
		console.log(e)
		var that = this;
		var text = "";
		text = utils.printConfig(0 ,200 ,200 ,1550 ,1);
		text += utils.printPrefeed(10);
		text += utils.printPostfeed(50);
		text += utils.printWidth(580);
		text += utils.printSpeed(1);
		text += utils.printAlign('l');
		
		//打印边框
		// text +=utils.printBox(5,5,570,470,1);
		text +=utils.printBox(0,0,570,1540,3);
		
		var memberInfo= uni.getStorageSync(preutils.userinfo)
		var site_name = check.strNullReplace(memberInfo.receipt_title,"临沂分拨中心") + '托运单';
		text += utils.printSetBoldStart();
		text += utils.printSetMag(2,2);
		text += utils.printText('T270',3,0,565,10,site_name)
		text += utils.printSetMag(0,0);
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(505,1088,570,1088,1);
		text += utils.printSetBoldStart();
		//配送方式
		text += utils.printText('T270',3,0,550,1098,tool.getDeliveryType(e)) 
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(505,0,505,1344,2);
		text += utils.printSetBoldStart();
		//路由
		text += utils.printText('T270',3,0,498,10,"路由：" + check.strNullReplace(tool.getToCity(e),""))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(460,896,505,896,1);
		text += utils.printSetBoldStart();
		//运单号
		text += utils.printText('T270',3,0,498,906,'运单号：'+check.strNullReplace(e.waybill_sn,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(460,0,460,1344,2);
		text += utils.printText('T270',3,0,453,10,check.strNullReplace("合计运价",""))
		
		//打印线条 横向
		text+=utils.printLine(415,224,460,224,1);
		text += utils.printText('T270',3,0,453,234,check.strNullReplace("运费",""))
		
		//打印线条 横向
		text+=utils.printLine(415,448,460,448,1);
		text += utils.printText('T270',3,0,453,458,check.strNullReplace("送货费",""))
		
		//打印线条 横向
		text+=utils.printLine(415,672,460,672,1);
		text += utils.printText('T270',3,0,453,682,check.strNullReplace("中转费",""))
		
		//打印线条 横向
		text+=utils.printLine(415,896,460,896,1);
		text += utils.printText('T270',3,0,453,906,check.strNullReplace("代收货款",""))
		
		//打印线条 横向
		text+=utils.printLine(415,1120,460,1120,1);
		text += utils.printText('T270',3,0,453,1130,check.strNullReplace("",""))
		
		//打印线条 竖向
		text+=utils.printLine(415,0,415,1344,2);
		// 价格
		text += utils.printSetBoldStart();
		// 合计运价
		text += utils.printText('T270',3,0,408,10,check.strNullReplace(e.all_order_amount,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(370,224,415,224,1);
		text += utils.printSetBoldStart();
		// 运费
		text += utils.printText('T270',3,0,408,234,tool.getOrderAmount(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(370,448,415,448,1);
		text += utils.printSetBoldStart();
		// 送货费
		text += utils.printText('T270',3,0,408,458,check.strNullReplace(e.delivery_fee,""))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(370,672,415,672,1);
		text += utils.printSetBoldStart();
		// 中转费
		text += utils.printText('T270',3,0,408,682,check.strNullReplace(e.transit_fee,""))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(370,896,415,896,1);
		text += utils.printSetBoldStart();
		// 代收货款
		text += utils.printText('T270',3,0,408,906,check.strNullReplace(e.advance_amount,""))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(370,1120,415,1120,1);
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,408,1130,check.strNullReplace("",""))
		text += utils.printSetBoldEnd();
		 
		 
		//打印线条 竖向
		text+=utils.printLine(370,0,370,1344,2);
		text += utils.printText('T270',3,0,363,10,check.strNullReplace("发货：",""))
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,363,80,tool.printSendName(e))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(325,672,370,672,1);
		text += utils.printText('T270',3,0,363,682,check.strNullReplace("收货：",""))
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,363,752,tool.printTakeName(e))
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(325,0,325,1540,2);
		text += utils.printText('T270',3,0,318,10,check.strNullReplace("目的地址：",""))
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,318,130,check.strNullReplace(e.transit_destination,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(280,1120,325,1120,1);
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,318,1130,"备注："+check.strNullReplace(e.remark,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(280,0,280,1540,2);
		text += utils.printText('T270',3,0,273,10,check.strNullReplace("收货地址：",""))
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,273,130,check.strNullReplace(e.take_address,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(235,1120,280,1120,1);
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,273,1130,"回单："+tool.printReceipt(e))
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(235,0,235,1540,2);
		text += utils.printText('T270',3,0,228,10,check.strNullReplace("货物名称",""))
		//打印线条 横向
		text+=utils.printLine(190,256,235,256,1);
		text += utils.printText('T270',3,0,228,266,check.strNullReplace("数量",""))
		//打印线条 横向
		text+=utils.printLine(190,512,235,512,1);
		text += utils.printText('T270',3,0,228,522,check.strNullReplace("包装",""))
		//打印线条 横向
		text+=utils.printLine(190,768,235,768,1);
		text += utils.printText('T270',3,0,228,778,check.strNullReplace("重量(KG)",""))
		//打印线条 横向
		text+=utils.printLine(190,1024,235,1024,1);
		text += utils.printText('T270',3,0,228,1034,check.strNullReplace("体积(方)",""))
		//打印线条 横向
		text+=utils.printLine(190,1280,235,1280,1);
		text += utils.printText('T270',3,0,228,1290,check.strNullReplace("货号",""))
		
		
		//打印线条 竖向
		text+=utils.printLine(190,0,190,1540,2);
		text += utils.printSetBoldStart();
		// 货物名称
		text += utils.printText('T270',3,0,183,10,tool.printGoodsName(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(145,256,190,256,1);
		text += utils.printSetBoldStart();
		// 数量
		text += utils.printText('T270',3,0,183,266,tool.printGoodsNum(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(145,512,190,512,1);
		text += utils.printSetBoldStart();
		// 包装
		text += utils.printText('T270',3,0,183,522,tool.printGoodsPack(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(145,768,190,768,1);
		text += utils.printSetBoldStart();
		// 重量
		text += utils.printText('T270',3,0,183,778,tool.printGoodsWeight(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(145,1024,190,1024,1);
		text += utils.printSetBoldStart();
		// 体积
		text += utils.printText('T270',3,0,183,1034,tool.printGoodsVolume(e))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(145,1280,190,1280,1);
		text += utils.printSetBoldStart();
		// 货号
		text += utils.printText('T270',3,0,183,1290,check.strNullReplace(e.goodsn,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 竖向
		text+=utils.printLine(145,0,145,1540,2);
		// text += utils.cutLine270(65,{x: 138,y: 10}, "托运须知:1.不得虚报货名、危险品禁运物品不予托运，否则出现一切损失由托运人负责；2.所托运物品如果报价，发生货损货差时，按货物实际损失的价格赔偿，最高不超过该批货物生命保价；3.如未保价发生货损货差时最多不超过运费的10倍，代收款不作为赔偿依据，已经签收的不再赔偿；如您在本公司托运货物，意味着您已知并认可托运须知。查款电话:0539-7208836,查货电话:0539-8535656");
		text += utils.cutLine270(65,{x: 138,y: 10}, "提示："+check.strNullReplace(e.receipt_detail,""));
		//打印线条 竖向
		text+=utils.printLine(45,0,45,1540,2);
		 text += utils.printSetBoldStart();
		 text += utils.printText('T270',3,0,38,10,"打印时间："+tool.printNewDate())
		 text += utils.printSetBoldEnd();
		   
		//打印线条 横向
		text+=utils.printLine(0,600,45,600,1);
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,38,610,"制单人："+check.strNullReplace(memberInfo.nickname,""))
		text += utils.printSetBoldEnd();
		//打印线条 横向
		text+=utils.printLine(0,1024,45,1024,1);
		text += utils.printSetBoldStart();
		text += utils.printText('T270',3,0,38,1034,"客服电话："+check.strNullReplace(memberInfo.mobile,""))
		text += utils.printSetBoldEnd();
		
		//打印线条 横向
		text+=utils.printLine(325,1344,570,1344,1);
		var qrcontext = "https://3plapidev1.chengxin56.net/weixinArrive/"
					+"?waybill_type=2&waybill_sn="+e.waybill_sn
					+"&waybill_id="+e.waybill_id;
		// 二维码
		text += utils.printQr(390,1360,2,4,qrcontext); 
		text += utils.printText('T270',3,0,375,1370,'扫码查询订单')
		 
		text += utils.printEnd();
		text += utils.print();
		console.log(text)
		var arrayBuffer = plus.android.invoke(text, 'getBytes', 'gbk');
		outputStream.write(arrayBuffer);
		outputStream.flush();
	},
}